﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommLink
{
    /// <summary>
    /// Communication link abstract implementation definition.
    /// </summary>
    public abstract class CommLinkAbstract
    {
        /// <summary>
        /// The name of the communication media
        /// </summary>
        /// <returns>String name of the communicaiton media</returns>
        public abstract string getName();

        /// <summary>
        /// Closes up anyform of open comm channels
        /// </summary>
        public abstract void closeConnection();

        /// <summary>
        /// Opens connection channels
        /// </summary>
        public abstract void openConnection();

        /// <summary>
        /// Sends a data buffer.
        /// </summary>
        /// <param name="OutData">Byte array to sned</param>
        /// <returns>Error status</returns>
        public abstract int messageSend(byte[] OutData);

        /// <summary>
        /// Delegate for the message received event.
        /// </summary>
        /// <param name="msgData">Reference to the message data byte array</param>
        public delegate void MessageReceived(byte[] msgData);

        /// <summary>
        /// Message received event providing the byte array data received.
        /// </summary>
        public abstract event MessageReceived OnMessageReceived;

        /// <summary>
        /// Connection state events
        /// </summary>
        public enum ConnectionStates
        {
            /// <summary>
            /// channel is connected
            /// </summary>
            Connected,
            /// <summary>
            /// channel is not connected
            /// </summary>
            NotConnected,
            /// <summary>
            /// server side error while trying to establish communication channel
            /// </summary>
            ServerError
        }

        /// <summary>
        /// Delegate for the connection status change event.
        /// </summary>
        public delegate void ConnectionStatusChange(ConnectionStates state);

        /// <summary>
        /// Connection status change event.
        /// </summary>
        public abstract event ConnectionStatusChange OnConnectionStatusChange;
    }
}
